package cn.com.utt.unms.mapper;

import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import cn.com.utt.unms.pojo.PagePub;

@Mapper
public interface PagePubMapper {

	@Select("select * from page_pub where page_id=#{pageId}")
	PagePub queryPagePubByPageId(@Param("pageId") Long pageId);

	@Delete("delete from page_pub where page_type=#{pageType} and cfg_id=#{cfgId}")
	void deletePagePubByType(@Param("pageType") byte pageType, @Param("cfgId") Long cfgId);

	@Insert("insert into page_pub(cfg_id,page_type,page_id,path) values(#{cfgId},#{pageType},#{pageId},#{path})")
	void savePagePub(PagePub pagePub);

	@Select("select * from page_pub where user_id=#{userId} and page_type=#{pageType}")
	PagePub queryPagePubByType(@Param("pageType") byte pageType, @Param("userId") Long userId);

	@Delete("delete from page_pub where user_id=#{userId}")
	void deletePagePub(@Param("userId") Long userId);

	@Select({ "<script>", "select * ", "FROM page_pub", "WHERE ", "page_id IN",
			"<foreach item='item' index='index' collection='pageIds'", "open='(' separator=',' close=')'>", "#{item}",
			"</foreach>", "</script>" })
	List<PagePub> queryPagePubByPageIds(@Param("pageIds") List<Long> pageIds);

}
